package net.spatula.tally_ho.model;

/* Copyright 2006 Nicklas R Johnson
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 
 * 
 * Unless required by applicable law or agreed to in writing, software 
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License.
 */

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.SequenceGenerator;
import javax.persistence.ManyToMany;
import javax.persistence.Transient;
import javax.persistence.Embedded;
import javax.persistence.Basic;
import javax.persistence.JoinTable;

@Entity
public class Article implements Serializable {

    @Id
    @SequenceGenerator(name = "articleSequence", sequenceName = "article_object_id_seq")
    @GeneratedValue(generator="articleSequence", strategy = GenerationType.SEQUENCE)
    @Column(name="object_id")
    private long objectId;

    private String title;

    private long mailed;

    @Column(name = "thumbs_up")
    private long thumbsUp;

    private boolean visible;

    private String status;

    private String body;

    private String summary;

    private long views;

    @Column(name = "create_date")
    private Timestamp createDate;

    private long version;

    @Column(name = "thumbs_down")
    private long thumbsDown;
    
    @Column(name = "spam_abuse")
    private long spamAbuse;

    @Column(name = "change_summary")
    private String changeSummary;

    private String adjective;

    @OneToOne
    @JoinColumn(name = "changer")
    private Account changer;

    @OneToOne
    @JoinColumn(name = "creator")
    private Account creator;

    @OneToOne
    @JoinColumn(name = "section")
    private Section section;

    @OneToOne
    @JoinColumn(name = "object_id", referencedColumnName = "root_source", insertable = false, updatable = false)
    private ArticleMessageBoardRoot messageBoardRoot;
    
    @ManyToMany
    @JoinTable(name="article_votes", inverseJoinColumns = {@JoinColumn(name = "account_object_id", referencedColumnName = "object_id")})
    private Set<Account> articleVotes;

    private static final long serialVersionUID = 1L;

    public Article() {
        super();
    }

    public long getObjectId() {
        return this.objectId;
    }

    public void setObjectId(long objectId) {
        this.objectId = objectId;
    }

    public String getTitle() {
        return this.title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public long getMailed() {
        return this.mailed;
    }

    public void setMailed(long mailed) {
        this.mailed = mailed;
    }

    public long getThumbsUp() {
        return this.thumbsUp;
    }

    public void setThumbsUp(long thumbsUp) {
        this.thumbsUp = thumbsUp;
    }

    public boolean getVisible() {
        return this.visible;
    }

    public void setVisible(boolean visible) {
        this.visible = visible;
    }

    public String getStatus() {
        return this.status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public String getBody() {
        return this.body;
    }

    public void setBody(String body) {
        this.body = body;
    }

    public String getSummary() {
        return this.summary;
    }

    public void setSummary(String summary) {
        this.summary = summary;
    }

    public long getViews() {
        return this.views;
    }

    public void setViews(long views) {
        this.views = views;
    }

    public Timestamp getCreateDate() {
        return this.createDate;
    }

    public void setCreateDate(Timestamp createDate) {
        this.createDate = createDate;
    }

    public long getVersion() {
        return this.version;
    }

    public void setVersion(long version) {
        this.version = version;
    }

    public long getThumbsDown() {
        return this.thumbsDown;
    }

    public void setThumbsDown(long thumbsDown) {
        this.thumbsDown = thumbsDown;
    }

    public String getChangeSummary() {
        return this.changeSummary;
    }

    public void setChangeSummary(String changeSummary) {
        this.changeSummary = changeSummary;
    }

    public String getAdjective() {
        return this.adjective;
    }

    public void setAdjective(String adjective) {
        this.adjective = adjective;
    }

    public Account getChanger() {
        return this.changer;
    }

    public void setChanger(Account changer) {
        this.changer = changer;
    }

    public Account getCreator() {
        return this.creator;
    }

    public void setCreator(Account creator) {
        this.creator = creator;
    }

    public Section getSection() {
        return this.section;
    }

    public void setSection(Section section) {
        this.section = section;
    }

    public ArticleMessageBoardRoot getMessageBoardRoot() {
        return messageBoardRoot;
    }

    public void setMessageBoardRoot(ArticleMessageBoardRoot messageBoardRoot) {
        this.messageBoardRoot = messageBoardRoot;
    }

    
    public Set<Account> getArticleVotes() {
        return articleVotes;
    }

    
    public void setArticleVotes(Set<Account> articleVotes) {
        this.articleVotes = articleVotes;
    }

    
    public long getSpamAbuse() {
        return spamAbuse;
    }

    
    public void setSpamAbuse(long spamAbuse) {
        this.spamAbuse = spamAbuse;
    }

}
